import { defineStore } from 'pinia'

export const useCounterStore = defineStore({
  id: 'counter',
  // Initial state
  state: () => ({
    counter: 0, 
    id: '123'
  }),
  // Mutations
  getters: {
    doubleCount: (state) => state.counter * 2,
    getCount: (state) => {
      return state.counter
    },
    testGetter: (state) => {
      state.id = Math.random(10000)
    },
    countPx() {
      // counter + x
      return (x) => this.getCount + x
    }
  },
  // Actions
  actions: {
    increment() {
      this.counter++
    }
  }
})
